package com.supor.aiot.home.apdater;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.supor.aiot.home.R;
import com.supor.aiot.home.bean.WlanDescriptionBean;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

/**
 * Description :
 *
 * @author jyt
 * @date 2021/5/21
 */
public class WlanDescriptionAdapter extends RecyclerView.Adapter<WlanDescriptionAdapter.ViewHolder> {

    private LayoutInflater inflater;
    private Context mContext;
    private List<WlanDescriptionBean> mlist = new ArrayList<>();

    static class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_descripition;
        private ImageView image_guide;

        public ViewHolder(View itemView) {
            super(itemView);
            tv_descripition = itemView.findViewById(R.id.tv_descripition);
            image_guide = itemView.findViewById(R.id.image_guide);
        }
    }

    public WlanDescriptionAdapter(Context mcontext, List<WlanDescriptionBean> mlist) {
        this.mContext = mcontext;
        this.mlist = mlist;
        inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public WlanDescriptionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_wlandescription, null);
        WlanDescriptionAdapter.ViewHolder viewHolder = new WlanDescriptionAdapter.ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final WlanDescriptionAdapter.ViewHolder holder, final int position) {
        holder.image_guide.setImageResource(mlist.get(position).getImageid());
        holder.tv_descripition.setText(mlist.get(position).getDescription());
    }

    @Override
    public int getItemCount() {
        return mlist.size();
    }


}

